package com.lyf.scm.plan.api.controller;

import com.lyf.scm.plan.api.dto.SalesPlanPermissionsDTO;
import com.lyf.scm.plan.domain.repository.SalesPlanPermissionsRespository;
import com.lyf.scm.plan.domain.service.SalesPlanPermissionsService;
import com.rome.arch.core.clientobject.Response;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 测试controller
 *
 * @author Martin
 * @date 2020-10-31 11:25
 */
@RestController
@RequestMapping("/permissions")
public class SalesPlanPermissionsController {

    @Resource
    private SalesPlanPermissionsService salesPlanPermissionsService;

    @GetMapping("/_userid/{userId}")
    public Response<List<SalesPlanPermissionsDTO>> listByUserId(@PathVariable Long userId) {
        return Response.builderSuccess(salesPlanPermissionsService.listByUserId(userId));
    }

    @PostMapping("/_batch")
    public Response<Integer> batchSave(@RequestBody List<SalesPlanPermissionsDTO> list) {
        return Response.builderSuccess(salesPlanPermissionsService.batchSave(list));
    }
    @PutMapping()
    public Response<Boolean> updateById(@RequestBody SalesPlanPermissionsDTO dto) {
        return Response.builderSuccess(salesPlanPermissionsService.updateById(dto));
    }
}
